package com.example.homework7;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.fragment.app.Fragment;

public class fragment5 extends Fragment {


    public fragment5() {
        super(R.layout.fragment5);
    }
    public void onViewCreated(View view, Bundle saveInstanceState) {
        EditText editTextnumber = getView().findViewById(R.id.editTextNumber);
        EditText editTextpassword = getView().findViewById(R.id.editTextTextPassword2);
        super.onViewCreated(view, saveInstanceState);

        Button xxx = getView().findViewById(R.id.button);
        xxx.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SharedPreferences settings = getActivity().getSharedPreferences("aa", Context.MODE_PRIVATE);
                SharedPreferences.Editor editor = settings.edit();
                editor.putString("number",editTextnumber.getText().toString());
                editor.putString("password",editTextpassword.getText().toString());
                editor.commit();
                Toast.makeText(getActivity(),"保存成功",Toast.LENGTH_SHORT).show();
            }
        });

        SharedPreferences settingss = getActivity().getSharedPreferences("aa", Context.MODE_PRIVATE);
        String number = settingss.getString("number","");
        String password = settingss.getString("password","");
        editTextnumber.setText(number);
        editTextpassword.setText(password);
















    }
}